package com.luhuiguo.sso.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import com.luhuiguo.sso.entity.AuditableEntity;

@Entity
@Table(name = "t_site")
public class Site extends AuditableEntity {

	private static final long serialVersionUID = 3588588992320712987L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	@Column(unique = true, nullable = false)
	private String url;

	public Site() {
		super();
	}

	public Site(String url) {
		super();
		this.url = url;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Override
	public boolean equals(Object other) {
		if (!(other instanceof Site)) {
			return false;
		}
		Site castOther = (Site) other;
		return new EqualsBuilder().append(this.getUrl(), castOther.getUrl())
				.isEquals();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(getUrl()).toHashCode();
	}

	@Override
	public String toString() {
		return url;
	}

}
